package com.hl.mapper;

import com.hl.pojo.Users;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface UserMapper {
    @Insert("insert into users(user_name,location,user_account,password,phone_number) values (#{userName},#{location},#{userAccount},#{password},#{phoneNumber})")
    public int add(Users users);

    //后台查询用户数据
    List<Users> selectAll(String keyword);

    //后台修改用户信息
    @Update("update users set user_name = #{userName},user_account = #{userAccount},password = #{password},phone_number = #{phoneNumber},location = #{location},points = #{points} where user_id = #{userId}")
    int updateUser(@Param("userName") String userName, @Param("userAccount") String userAccount,@Param("password") String password , @Param("phoneNumber") String phoneNumber,@Param("location") String location,@Param("points") Integer points,@Param("userId") Integer userId);

    @Delete("delete from users where user_id = #{userId}")
    int deleteUser(Integer userId);
}
